<!--- do we really need to set cancelView?  since the template is included, it gets the returnView value from this page.  cancelView should be a param defaulted to returnView in the included template --->
<cfparam name="Payment_ID" type="integer" default="0" />
<cfparam name="Scholarship_ID" type="integer" default="0" />
<cfparam name="Payment_Schedule_ID" type="integer" default="0" />
<cfparam name="returnView" type="string" default="payments" />
<cfparam name="passback" type="string" default="" />

<cfif StructKeyExists(url, "cfgridkey")>
	<cfset Payment_ID = cfgridkey />
</cfif>

<cfscript>
	paymentGateway = new assets.calgrants.com.gateway.PaymentGateway();
	payment = paymentGateway.get(Payment_ID = Payment_ID);
	if (payment.getScholarship_ID() eq 0) {
		if (Scholarship_ID gt 0) {
			payment.setScholarship_ID(Scholarship_ID);
		};
		if (Payment_Schedule_ID gt 0) {
			payment.setPayment_Schedule_ID(Payment_Schedule_ID);
		};
	};
</cfscript>

<cfif IsNumeric(payment.getPayment_ID()) and  payment.getPayment_ID() eq 0 and (payment.getScholarship_ID() eq 0 or payment.getPayment_Schedule_ID() eq 0)>

	<div class="alert alert-info notFound">Payment requires a valid scholarship and a scheduled payment</div>
	
<!--- <cfelseif payment.getScholarship_ID() eq 0>

	<cfset cancelView = returnView />
	<cfthrow message="Scholarship_ID is required when Payment_ID is 0" type="Invalid">
	<cfinclude template="/assets/calgrants/ui/forms/selectSchoalrship.cfm">

<cfelseif payment.getScholarship_ID() gt 0 and payment.getPayment_Schedule_ID() eq 0>

	<cfset cancelView = returnView />
	<cfthrow message="Payment_Schedule_ID is required when Payment_ID is 0" type="Invalid">
	<cfinclude template="/assets/calgrants/ui/forms/selectPaymentSchedule.cfm"> --->

<cfelseif IsNumeric(payment.getPayment_ID()) and payment.getScholarship_ID() gt 0 and payment.getPayment_Schedule_ID() gt 0>
	
	<cfscript>
		base = new assets.calgrants.com.Base();
		passbackQueryString = base.passbackToQueryString(passback);
		degreeLevels = base.getDegreeLevels();
		attendanceLevels = base.getAttendanceLevels();
		storedProcedureGateway = new assets.calgrants.com.gateway.StoredProcedureGateway();
		scholarshipGateway = new assets.calgrants.com.gateway.ScholarshipGateway();
		qScholarship = scholarshipGateway.query(Scholarship_ID = payment.getScholarship_ID());
		scholarship = scholarshipGateway.get(Scholarship_ID = payment.getScholarship_ID());
		isPBS = base.isPBSScholarshipType(Scholarship_Type = scholarship.getScholarship_Type());
		institutionGateway = new assets.calgrants.com.gateway.InstitutionGateway();
		//qInstitutions = institutionGateway.query();
		institution1 = institutionGateway.get(Institution_ID = IIf(IsNumeric(scholarship.getInstitution1_ID()), DE(scholarship.getInstitution1_ID()), 0));
		institution2 = institutionGateway.get(Institution_ID = IIf(IsNumeric(scholarship.getInstitution2_ID()), DE(scholarship.getInstitution2_ID()), 0));
		institution3 = institutionGateway.get(Institution_ID = IIf(IsNumeric(scholarship.getInstitution3_ID()), DE(scholarship.getInstitution3_ID()), 0));
		paymentScheduleGateway = new assets.calgrants.com.gateway.PaymentScheduleGateway();
		qPaymentSchedule = paymentScheduleGateway.query(Cohort = scholarship.getCohort(), Scholarship_Type = scholarship.getScholarship_Type(), Term_Type = institution1.getTerm_Type());
		paymentSchedule = paymentScheduleGateway.get(Payment_Schedule_ID = payment.getPayment_Schedule_ID());
		//paymentGateway = new assets.calgrants.com.gateway.PaymentGateway();
		//qPayments = paymentGateway.query(Scholarship_ID = payment.getScholarship_ID());
		//scheduledPaymentScheduleIDs = ValueList(qPaymentSchedule.Payment_Schedule_ID);
		//initiatedPaymentScheduleIDs = ValueList(qPayments.Payment_Schedule_ID);
		//onSchedule = true;
		//onSchedulePaymentScheduleIDs = "";
		//offSchedulePayments = false;
		//offSchedulePaymentScheduleIDs = "";
		//openOffSchedulePaymentScheduleIDs = "";
	</cfscript>
	
	<!--- for new payments (only!) validate that all other payments are closed.  also look for off schedule payments and warn if any are found --->
	<!--- 
	<cfif payment.getPayment_ID() eq 0>
		<!--- 
		Example
		previousPaymentScheduleIDs: 200,201,202
		scheduledPaymentScheduleIDs: 100,101,102,103
		initiatedPaymentScheduleIDs: 200,101,102
		payment.getPayment_Schedule_ID(): 103
		case:
		payment 102 is not closed
		 --->
		 <!--- look for an off schedule payment --->
		<cfloop query="#qPayments#>
			<cfif ListFind(scheduledPaymentScheduleIDs, Payment_Schedule_ID) eq 0>
				<cfset offSchedulePayments = true />
				<cfset offSchedulePaymentScheduleIDs = ListAppend(offSchedulePaymentScheduleIDs, Payment_Schedule_ID) />
				<!--- <cfif base.getPaymentStatus( --->
			</cfif>
		</cfloop>
		<!--- ensure previous payments are closed --->
		<cfloop index="scheduledPaymentScheduleID" list="#scheduledPaymentScheduleIDs#">
			<cfif ListFind(initiatedPaymentScheduleIDs, scheduledPaymentScheduleID)>
			
			</cfif>
		</cfloop>
	</cfif> --->
	
	<!--- 
	Conditions to create a payment record
	-------------------------------------
	1. Must have claimed and if cohort 5 pbs, must have authorized/given consent
	2. Must have selected an institution
	3. Institution must be approved, not disqualified, not deleted, accredited and degree-granting
	4. Must have completed the orientation
	5. Must have selected a payment method and if EFT, provided an account number and routing number
	6. All previous payments must be resolved
	
	Conditions to approve payment
	-----------------------------
	8. Must have provided enrollment or performance documentation
	9. If enrollment documentation must have 6 units and declared major
	10. If performance documentation must have 2.0 GPA and 6 credits
	 --->

	<script type="text/javascript">
	<!--
		<cfoutput>
			var verificationType = "#paymentSchedule.getVerification_Type()#";
			var today = "#DateFormat(Now(), 'm/d/yyyy')#";
		</cfoutput>
		
		var toggleOptOut = function() {
			if ($("#Opt_Out").is(":checked")) {
				$("#optOutReasonContainer").show();
				$("#paymentDetailsContainer").hide();
			} else {
				$("#optOutReasonContainer").hide();
				$("#paymentDetailsContainer").show();
			}
		}
		var setToday = function(selId) {
			$("#" + selId).val(today);	
		}
		var validate = function() {
			var valid = true;
			var errors = "";
			if ($("#Opt_Out").is(":checked") && $("#Opt_Out_Reason").val() == "") {
				valid = false;
				errors += "Reason is required when \"No payment\" is selected\n"
			}
			if (!valid) {
				alert(errors);
			}
			return valid;
		}
		$(function() {
			var approvalDatePicker = $("#Approval_Date").kendoDatePicker().data("kendoDatePicker");
			var paymentSubmittedDatePicker = $("#Payment_Submitted_Date").kendoDatePicker().data("kendoDatePicker");
			var paymentDatePicker = $("#Payment_Date").kendoDatePicker().data("kendoDatePicker");
			var institution1DocumentDatePicker = $("#Institution1_Document_Date").kendoDatePicker().data("kendoDatePicker");
			var institution2DocumentDatePicker = $("#Institution2_Document_Date").kendoDatePicker().data("kendoDatePicker");
			var institution3DocumentDatePicker = $("#Institution3_Document_Date").kendoDatePicker().data("kendoDatePicker");
			$("#paymentModal").modal();
			resizeModal("paymentModal");
		});
	//-->
	</script>
	
	<cfoutput>
	
		<cfform id="paymentForm" name="paymentForm" action="#script_name#" method="post" onsubmit="return validate();">
			<cfinput type="hidden" name="action" value="savePayment" />
			<cfinput type="hidden" name="view" value="#returnView#" />
			<cfinput type="hidden" name="Payment_ID" value="#payment.getPayment_ID()#" />
			<cfinput type="hidden" name="Scholarship_ID" value="#payment.getScholarship_ID()#" />
			<cfinput type="hidden" name="Payment_Schedule_ID" value="#payment.getPayment_Schedule_ID()#" />
			<cfinput type="hidden" name="Institution1_ID" value="#scholarship.getInstitution1_ID()#" />
			<cfinput type="hidden" name="Institution2_ID" value="#scholarship.getInstitution2_ID()#" />
			<cfinput type="hidden" name="Institution3_ID" value="#scholarship.getInstitution3_ID()#" />
			<cfif IsDefined("passback")>
				<cfloop index="keyValue" list="#passback#" delimiters=";">
					<cfif ListFirst(keyValue) neq "Scholarship_ID">
						<cfinput type="hidden" name="#ListFirst(keyValue)#" value="#ListLast(keyValue)#" />
					</cfif>
				</cfloop>
			</cfif>
			<!--- <div class="row-fluid">
				<div class="span6">
					<dl class="dl-horizontal">
						<dt>Scholar</dt>
						<dd>#scholarship.getFirst_Name()# #scholarship.getLast_Name()#</dd>
						<dt>Cohort</dt>
						<dd>#scholarship.getCohort()#</dd>
						<dt>Scholarship Type</dt>
						<dd>#scholarship.getScholarship_Type()#</dd>
					</dl>
				</div>
				<div class="span6">
					<dl class="dl-horizontal">
						<dt>Term</dt>
						<dd>#paymentSchedule.getTerm()#</dd>
						<dt>Verification Type</dt>
						<dd>#paymentSchedule.getVerification_Type()#</dd>
						<dt>Payment Amount</dt>
						<dd>#DollarFormat(paymentSchedule.getPayment_Amount())#</dd>
					</dl>
				</div>
			</div> --->
			
			<div id="paymentModal" class="modal modal-fullscreen" data-backdrop="static">
				<div class="modal-header">
					<h3>Payment</h3>
				</div>
				<div class="modal-body">
					<div class="container-fluid">
						<div class="row-fluid">
							<cfif NOT IsDate(scholarship.getClaim_Date())>
								<div class="span12">
									Scholarship not claimed
								</div>
							<cfelseif NOT IsNumeric(scholarship.getInstitution1_ID()) or scholarship.getInstitution1_ID eq 0>
								<div class="span12">
									No instituiton selected
								</div>
							<cfelseif institution1.getDeleted() eq 1 or institution1.getDisqualified() eq 1 or institution1.getApproved() eq 0 or institution1.getAccredited() eq 0 or institution1.getDegree_Granting() eq 0>
								<div class="span12">
									Institution is not valid
								</div>
							<cfelseif scholarship.getCohort() eq 5 and scholarship.getScholarship_Type eq "performance based scholarship" and scholarship.getOrientation_Completed() eq 0>
								<div class="span12">
									Orientation not completed for Performance Based Scholarship
								</div>
							<!--- <cfelseif scholarship.getPayment_Method() neq "eft" and scholarship.getPayment_Method() neq "check">
								<div class="span12">
								Payment method not selected
								</div> --->
							<cfelse>
								<!--- scholar address --->
								<div class="span4">
									<h4>Scholar</h4>
									<div class="text-control clearfix">
										<label>Recipient</label>
										#scholarship.getFirst_Name()# #scholarship.getLast_Name()#<br />
										#scholarship.getAddress()#<br />
										#scholarship.getCity()#, CA #scholarship.getZip_Code()#<br />
										<cfif Len(Trim(scholarship.getPhone1())) gt 0>
											#base.formatPhone(scholarship.getPhone1())#<br />
										</cfif>
										<cfif Len(Trim(scholarship.getPhone2())) gt 0>
											#base.formatPhone(scholarship.getPhone2())#<br />
										</cfif>
										<cfif Len(Trim(scholarship.getEmail())) gt 0>
											<a href="mailto:#LCase(scholarship.getEmail())#">#LCase(scholarship.getEmail())#</a><br />
										</cfif>
									</div>
									<table class="table table-striped table-bordered">
										<tr>
											<th>Cohort</th>
											<td>#paymentSchedule.getCohort()#</td>
										</tr>
										<tr>
											<th>Scholarship Type</th>
											<td>#paymentSchedule.getScholarship_Type()#</td>
										</tr>
										<tr>
											<th>Attendance Level</th>
											<td>#scholarship.getAttendance_Level()#</td>
										</tr>
										<tr>
											<th>Degree Sought</th>
											<td>#scholarship.getDegree_Level()#</td>
										</tr>
									</table>
								</div>
								<!--- verification --->
								<!--- <div class="span3">
									<div class="text-control clearfix">
										<label>Verification Type</label>
										#paymentSchedule.getVerification_Type()#
									</div>
									<div class="text-control clearfix">
										<label>Term</label>
										#paymentSchedule.getTerm()#
									</div>
								</div> --->
								<!--- institutions --->
								<div class="span4">
									<h4>Primary College University</h4>
									<!--- College/University name --->
									<div class="text-control clearfix">
										<label>College/University</label>
										#institution1.getInstitution()#
									</div>
									<!--- Term type --->
									<div class="text-control clearfix">
										<label>Term Type</label>
										#institution1.getTerm_Type()#
									</div>
									<!--- Financial aid contact --->
									<div class="text-control clearfix">
										<label>Financial Aid Contact</label>
										<cfif Len(Trim(institution1.getFAO_First_Name())) gt 0 or Len(Trim(institution1.getFAO_Last_Name())) gt 0>
											#institution1.getFAO_First_Name()# #institution1.getFAO_Last_Name()#<br />
										</cfif>
										<cfif Len(Trim(institution1.getFAO_Phone())) gt 0>
											#base.FormatPhone(institution1.getFAO_Phone())#<br />
										</cfif>
										<cfif Len(Trim(institution1.getFAO_Email())) gt 0>
											<a href="mailto:#LCase(institution1.getFAO_Email())#">#LCase(institution1.getFAO_Email())#</a><br />
										</cfif>
									</div>
									<!--- Verification - enrollment date, units/credits, attendance level, degree level, etc. --->
									<cfif paymentSchedule.getVerification_Type() eq "enrollment">
										<div class="kendo-control clearfix">
											<label>Class Schedule Recieved Date</label>
											<cfinput type="text" id="Institution1_Document_Date" name="Institution1_Document_Date" value="#DateFormat(payment.getInstitution1_Document_Date(), 'm/d/yyyy')#" required="no" validate="date" message="Class Schedule Recieved Date must be a valid date" style="width: 120px" /> <a href="##" onclick="setToday('Institution1_Document_Date'); return false;" class="btn btn-mini btn-primary">Today</a>
										</div>
										<cfif isPBS>
											<div class="clearfix">
												<label>Units</label>
												<cfselect id="Institution1_Enrollment_Units" name="Institution1_Enrollment_Units">
													<option value="">Select...</option>
													<cfloop index="u" from="1" to="24">
														<option value="#u#"<cfif payment.getInstitution1_Enrollment_Units() eq u> selected</cfif>>#u#</option>
													</cfloop>
												</cfselect>
											</div>
										<cfelse>
											<div class="clearfix">
												<label>Attendance Level</label>
												<cfselect id="Institution1_Enrollment_Attendance_Level" name="Institution1_Enrollment_Attendance_Level">
													<option value="">Select...</option>
													<option value="Full-time"<cfif payment.getInstitution1_Enrollment_Attendance_Level() eq "Full-time"> selected</cfif>>Full-time (12 or more units)</option>
													<option value="Half-time"<cfif payment.getInstitution1_Enrollment_Attendance_Level() eq "Half-time"> selected</cfif>>Half-time (6 to 11 units)</option>
													<option value="Part-time"<cfif payment.getInstitution1_Enrollment_Attendance_Level() eq "Part-time"> selected</cfif>>Less than half-time (less than 6 units)</option>
												</cfselect>
											</div>
										</cfif>
										<div class="clearfix">
											<label>Degree Level</label>
											<cfselect id="Institution1_Enrollment_Degree_Level" name="Institution1_Enrollment_Degree_Level">
												<option value="">Select...</option>
												<option value="Bachelors"<cfif payment.getInstitution1_Enrollment_Degree_Level() eq "Bachelors" or scholarship.getDegree_Level() eq "Bachelors"> selected</cfif>>Bachelors</option>
												<option value="Associates"<cfif payment.getInstitution1_Enrollment_Degree_Level() eq "Associates" or scholarship.getDegree_Level() eq "Associates"> selected</cfif>>Associates</option>
												<option value="Certificate"<cfif payment.getInstitution1_Enrollment_Degree_Level() eq "Certificate" or scholarship.getDegree_Level() eq "Certificate"> selected</cfif>>Certificate</option>
											</cfselect>
										</div>
									<cfelseif paymentSchedule.getVerification_Type() eq "performance">
										<div class="kendo-control clearfix">
											<label>Transcript Recieved Date</label>
											<cfinput type="text" id="Institution1_Document_Date" name="Institution1_Document_Date" value="#DateFormat(payment.getInstitution1_Document_Date(), 'm/d/yyyy')#" required="no" validate="date" message="Transcript Recieved Date must be a valid date" style="width: 120px" />
										</div>
										<div class="clearfix">
											<label>Credits</label>
											<cfselect id="Institution1_Performance_Credits" name="Institution1_Performance_Credits">
												<option value="">Select...</option>
												<cfloop index="u" from="1" to="24">
													<option value="#u#"<cfif payment.getInstitution1_Performance_Credits() eq u> selected</cfif>>#u#</option>
												</cfloop>
											</cfselect>
										</div>
										<div class="clearfix">
											<label>GPA</label>
											<cfinput type="text" id="Institution1_Performance_GPA" name="Institution1_Performance_GPA" value="#payment.getInstitution1_Performance_GPA()#" required="no" validate="float" message="GPA must be a number.  Decimals such as 3.25 are ok." size="5" maxlength="5">
										</div>
									</cfif>
									<cfif scholarship.getInstitution2_ID() gt 0>
										<h4>Secondary College University</h4>
										<div class="text-control clearfix">
											<label>College/University</label>
											#institution2.getInstitution()#
										</div>
										<div class="text-control clearfix">
											<label>Term Type</label>
											#institution2.getTerm_Type()#
										</div>
										<div class="text-control clearfix">
											<label>Financial Aid Contact</label>
											<cfif Len(Trim(institution2.getFAO_First_Name())) gt 0 or Len(Trim(institution2.getFAO_Last_Name())) gt 0>
												#institution2.getFAO_First_Name()# #institution2.getFAO_Last_Name()#<br />
											</cfif>
											<cfif Len(Trim(institution2.getFAO_Phone())) gt 0>
												#base.FormatPhone(institution2.getFAO_Phone())#<br />
											</cfif>
											<cfif Len(Trim(institution2.getFAO_Email())) gt 0>
												<a href="mailto:#LCase(institution2.getFAO_Email())#">#LCase(institution2.getFAO_Email())#</a><br />
											</cfif>
										</div>
										<cfif paymentSchedule.getVerification_Type() eq "enrollment">
											<div class="kendo-control clearfix">
												<label>Class Schedule Recieved Date</label>
												<cfinput type="text" id="Institution2_Document_Date" name="Institution2_Document_Date" value="#DateFormat(payment.getInstitution2_Document_Date(), 'm/d/yyyy')#" required="no" validate="date" message="Class Schedule Recieved Date must be a valid date" style="width: 120px" /> <a href="##" onclick="setToday('Institution2_Document_Date'); return false;" class="btn btn-mini btn-primary">Today</a>
											</div>
											<cfif base.isPBSScholarshipType(scholarship.getScholarship_Type())>
												<div class="clearfix">
													<label>Units</label>
													<cfselect id="Institution2_Enrollment_Units" name="Institution2_Enrollment_Units">
														<option value="">Select...</option>
														<cfloop index="u" from="1" to="24">
															<option value="#u#"<cfif payment.getInstitution2_Enrollment_Units() eq u> selected</cfif>>#u#</option>
														</cfloop>
													</cfselect>
												</div>
											<cfelse>
												<div class="clearfix">
													<label>Attendance Level</label>
													<cfselect id="Institution2_Enrollment_Attendance_Level" name="Institution2_Enrollment_Attendance_Level">
														<option value="">Select...</option>
														<option value="Full-time"<cfif payment.getInstitution2_Enrollment_Attendance_Level() eq "Full-time"> selected</cfif>>Full-time (12 or more units)</option>
														<option value="Half-time"<cfif payment.getInstitution2_Enrollment_Attendance_Level() eq "Half-time"> selected</cfif>>Half-time (6 to 11 units)</option>
														<option value="Part-time"<cfif payment.getInstitution2_Enrollment_Attendance_Level() eq "Part-time"> selected</cfif>>Less than half-time (less than 6 units)</option>
													</cfselect>
												</div>
											</cfif>
											<div class="clearfix">
												<label>Degree Level</label>
												<cfselect id="Institution2_Enrollment_Degree_Level" name="Institution2_Enrollment_Degree_Level">
													<option value="">Select...</option>
													<option value="Bachelors"<cfif payment.getInstitution2_Enrollment_Degree_Level() eq "Bachelors"> selected</cfif>>Bachelors</option>
													<option value="Associates"<cfif payment.getInstitution2_Enrollment_Degree_Level() eq "Associates"> selected</cfif>>Associates</option>
													<option value="Certificate"<cfif payment.getInstitution2_Enrollment_Degree_Level() eq "Certificate"> selected</cfif>>Certificate</option>
												</cfselect>
											</div>
										<cfelseif paymentSchedule.getVerification_Type() eq "performance">
											<div class="kendo-control clearfix">
												<label>Transcript Recieved Date</label>
												<cfinput type="text" id="Institution2_Document_Date" name="Institution2_Document_Date" value="#DateFormat(payment.getInstitution2_Document_Date(), 'm/d/yyyy')#" required="no" validate="date" message="Transcript Recieved Date must be a valid date" style="width: 120px" />
											</div>
											<div class="clearfix">
												<label>Credits</label>
												<cfselect id="Institution2_Performance_Credits" name="Institution2_Performance_Credits">
													<option value="">Select...</option>
													<cfloop index="u" from="1" to="24">
														<option value="#u#"<cfif payment.getInstitution2_Performance_Credits() eq u> selected</cfif>>#u#</option>
													</cfloop>
												</cfselect>
											</div>
											<div class="clearfix">
												<label>GPA</label>
												<cfinput type="text" id="Institution2_Performance_GPA" name="Institution2_Performance_GPA" value="#payment.getInstitution2_Performance_GPA()#" required="no" validate="float" message="GPA must be a number.  Decimals such as 3.25 are ok." size="5" maxlength="5">
											</div>
										</cfif>
									</cfif>
								</div>
								<div class="span4">
									<h4>Payment Details</h4>
									<cfif scholarship.getPayment_Method() eq "eft" and (IsUserInRole("Super User") or GetAuthUser() eq 620)>
										<table class="table table-striped table-bordered">
											<tr>
												<th>Payment Method</th>
												<td>#scholarship.getPayment_Method()#</td>
											</tr>
											<cfif scholarship.getPayment_Method() eq "eft">
												<tr>
													<th>Account Type</th>
													<td>#scholarship.getAccount_Type()#</td>
												</tr>
												<tr>
													<th>Routing Number</th>
													<td>#scholarship.getRouting_Number()#</td>
												</tr>
												<tr>
													<th>Account Number</th>
													<td>#scholarship.getAccount_Number()#</td>
												</tr>
											</cfif>
										</table>
									</cfif>
									<div class="clearfix text-control">
										<label class="checkbox">
											<input type="checkbox" id="Opt_Out" name="Opt_Out" value="1" onclick="toggleOptOut()"<cfif payment.getOpt_Out() eq 1> checked</cfif>>
											<strong>No payment</strong>
										</label>
									</div>
									<div id="optOutReasonContainer" class="clearfix" style="display: #IIf(payment.getOpt_Out() eq 1, DE('block'), DE('none'))#">
										<label>Reason</label>
										<cfselect name="Opt_Out_Reason" id="Opt_Out_Reason">
											<option value="">Select reason...</option>
											<option value="Low units"<cfif payment.getOpt_Out_Reason() eq "Low units"> selected</cfif>>Low units</option>
											<cfif paymentSchedule.getVerification_Type() eq "Performance">
												<option value="Low GPA"<cfif payment.getOpt_Out_Reason() eq "Low GPA"> selected</cfif>>Low GPA</option>
											</cfif>
											<option value="Not enrolled"<cfif payment.getOpt_Out_Reason() eq "Not enrolled"> selected</cfif>>Not enrolled</option>
											<option value="No AA/BA path"<cfif payment.getOpt_Out_Reason() eq "No AA/BA path"> selected</cfif>>No AA/BA path</option>
											<option value="Disqualified institution"<cfif payment.getOpt_Out_Reason() eq "Disqualified institution"> selected</cfif>>Disqualified institution</option>
											<option value="Balance over payment"<cfif payment.getOpt_Out_Reason() eq "Balance over payment"> selected</cfif>>Balance over payment</option>
											<option value="Funds unavailable"<cfif payment.getOpt_Out_Reason() eq "Funds unavailable"> selected</cfif>>Funds unavailable</option>
										</cfselect>
									</div>
									<div id="paymentDetailsContainer" style="display: #IIf(payment.getOpt_Out() eq 1, DE('none'), DE('block'))#">
										<div class="kendo-control clearfix">
											<label>Approval Date</label>
											<cfinput type="text" id="Approval_Date" name="Approval_Date" value="#DateFormat(payment.getApproval_Date(), 'm/d/yyyy')#" required="no" validate="date" message="Approval Date must be a valid date" style="width: 120px" /> <a href="##" onclick="setToday('Approval_Date'); return false;" class="btn btn-mini btn-primary">Today</a>
										</div>
										<div class="kendo-control clearfix">
											<label>Payment Submitted Date</label>
											<cfinput type="text" id="Payment_Submitted_Date" name="Payment_Submitted_Date" value="#DateFormat(payment.getPayment_Submitted_Date(), 'm/d/yyyy')#" required="no" validate="date" message="Payment Submitted Date must be a valid date" style="width: 120px" /> <a href="##" onclick="setToday('Payment_Submitted_Date'); return false;" class="btn btn-mini btn-primary">Today</a>
										</div>
										<div class="kendo-control clearfix">
											<label>Payment Date</label>
											<cfinput type="text" id="Payment_Date" name="Payment_Date" value="#DateFormat(payment.getPayment_Date(), 'm/d/yyyy')#" required="no" validate="date" message="Payment Date must be a valid date" style="width: 120px" /> <a href="##" onclick="setToday('Payment_Date'); return false;" class="btn btn-mini btn-primary">Today</a>
										</div>
										<div class="clearfix">
											<label>Payment Type</label>
											<cfselect id="Payment_Type" name="Payment_Type">
												<option value="">Select...</option>
												<option value="EFT"<cfif payment.getPayment_Type() eq "EFT"> selected</cfif>>EFT</option>
												<option value="Check"<cfif payment.getPayment_Type() eq "Check"> selected</cfif>>Check</option>
											</cfselect>
										</div>
										<!--- <div class="text-control clearfix">
											<label>Scheduled Payment Amount</label>
											#DollarFormat(paymentSchedule.getPayment_Amount())#
										</div> --->
										<div class="clearfix">
											<label>Payment Amount</label>
											<cfinput type="text" id="Payment_Amount" name="Payment_Amount" value="#payment.getPayment_Amount()#" required="no" validate="float" message="Payment Amount must be a number" maxlength="5">&nbsp;(#DollarFormat(paymentSchedule.getPayment_Amount())# scheduled)
										</div>
										<div class="clearfix">
											<label>Payment Reference</label>
											<cfinput type="text" id="Payment_Reference" name="Payment_Reference" value="#payment.getPayment_Reference()#" required="no">
										</div>
									</div>
									<div class="clearfix">
										<label>Notes</label>
										<textarea name="Notes" class="span9">#payment.getNotes()#</textarea>
									</div>
								</div>
							</cfif>
						</div>
						<!--- <div class="row-fluid">
							<!--- payment details --->
							<div class="span4">
								<div class="clearfix" style="margin-bottom: 6px;">
									<label class="checkbox">
										<input type="checkbox" id="Opt_Out" name="Opt_Out" value="1" onclick="toggleOptOut()"<cfif payment.getOpt_Out() eq 1> checked</cfif>>
										<strong>No payment</strong>
									</label>
								</div>
								<div id="optOutReasonContainer" class="clearfix" style="display: #IIf(payment.getOpt_Out() eq 1, DE('block'), DE('none'))#">
									<cfselect name="Opt_Out_Reason" id="Opt_Out_Reason">
										<option value="">Select reason...</option>
										<option value="Low units"<cfif payment.getOpt_Out_Reason() eq "Low units"> selected</cfif>>Low units</option>
										<cfif paymentSchedule.getVerification_Type() eq "Performance">
											<option value="Low GPA"<cfif payment.getOpt_Out_Reason() eq "Low GPA"> selected</cfif>>Low GPA</option>
										</cfif>
										<option value="Not enrolled"<cfif payment.getOpt_Out_Reason() eq "Not enrolled"> selected</cfif>>Not enrolled</option>
										<option value="No AA/BA path"<cfif payment.getOpt_Out_Reason() eq "No AA/BA path"> selected</cfif>>No AA/BA path</option>
										<option value="Disqualified institution"<cfif payment.getOpt_Out_Reason() eq "Disqualified institution"> selected</cfif>>Disqualified institution</option>
										<option value="Balance over payment"<cfif payment.getOpt_Out_Reason() eq "Balance over payment"> selected</cfif>>Balance over payment</option>
										<option value="Funds unavailable"<cfif payment.getOpt_Out_Reason() eq "Funds unavailable"> selected</cfif>>Funds unavailable</option>
									</cfselect>
								</div>
								<div id="paymentDetailsContainer" style="display: #IIf(payment.getOpt_Out() eq 1, DE('none'), DE('block'))#">
									<div class="kendo-control clearfix">
										<label>Approval Date</label>
										<cfinput type="text" id="Approval_Date" name="Approval_Date" value="#DateFormat(payment.getApproval_Date(), 'm/d/yyyy')#" required="no" validate="date" message="Approval Date must be a valid date" style="width: 120px" /> <a href="##" onclick="setToday('Approval_Date'); return false;" class="btn btn-mini btn-primary">Today</a>
									</div>
									<div class="kendo-control clearfix">
										<label>Payment Submitted Date</label>
										<cfinput type="text" id="Payment_Submitted_Date" name="Payment_Submitted_Date" value="#DateFormat(payment.getPayment_Submitted_Date(), 'm/d/yyyy')#" required="no" validate="date" message="Payment Submitted Date must be a valid date" style="width: 120px" /> <a href="##" onclick="setToday('Payment_Submitted_Date'); return false;" class="btn btn-mini btn-primary">Today</a>
									</div>
									<div class="kendo-control clearfix">
										<label>Payment Date</label>
										<cfinput type="text" id="Payment_Date" name="Payment_Date" value="#DateFormat(payment.getPayment_Date(), 'm/d/yyyy')#" required="no" validate="date" message="Payment Date must be a valid date" style="width: 120px" /> <a href="##" onclick="setToday('Payment_Date'); return false;" class="btn btn-mini btn-primary">Today</a>
									</div>
									<div class="clearfix">
										<label>Payment Type</label>
										<cfselect id="Payment_Type" name="Payment_Type">
											<option value="">Select...</option>
											<option value="EFT"<cfif payment.getPayment_Type() eq "EFT"> selected</cfif>>EFT</option>
											<option value="Check"<cfif payment.getPayment_Type() eq "Check"> selected</cfif>>Check</option>
										</cfselect>
									</div>
									<div class="text-control clearfix">
										<label>Scheduled Payment Amount</label>
										#DollarFormat(paymentSchedule.getPayment_Amount())#
									</div>
									<div class="clearfix">
										<label>Payment Amount</label>
										<cfinput type="text" id="Payment_Amount" name="Payment_Amount" value="#payment.getPayment_Amount()#" required="no" validate="float" message="Payment Amount must be a number" maxlength="5">
									</div>
									<div class="clearfix">
										<label>Payment Reference</label>
										<cfinput type="text" id="Payment_Reference" name="Payment_Reference" value="#payment.getPayment_Reference()#" required="no">
									</div>
								</div>
								<div class="clearfix">
									<label>Notes</label>
									<textarea name="Notes" class="span9">#payment.getNotes()#</textarea>
								</div>
							</div>
						</div> --->
					</div>
				</div>
				<div class="modal-footer">
					<cfif returnView eq "editScholarship">
						<a href="?view=#returnView#&Scholarship_ID=#scholarship.getScholarship_ID()#" class="btn btn-success">Cancel</a>
					<cfelse>
						<a href="?view=#returnView#&#passbackQueryString#" class="btn btn-success">Cancel</a>
					</cfif>
					<cfinput type="submit" name="saveButton" class="btn btn-success" value="Save" />
					<cfif (IsUserInRole("Super User") OR GetAuthUser() eq 620)>
						<cfinput type="submit" name="receiptButton" class="btn btn-success" value="Save + Generate Authorization" />
					</cfif>
					<!--- <a href="?view=#returnView#&#passbackQueryString#" class="btn btn-success">Cancel</a>
					<button type="submit" name="saveButton" class="btn btn-success">Save</button> --->
				</div>
			</div>
		</cfform>
	</cfoutput>
	
<cfelse>
	<div class="alert alert-info notFound">Workshop not found</div>
</cfif>
